3 largest elements in an ArrayΒΆ

def get_3_largest(arr, arr_size):
    # There should be atleast two elements
    if (arr_size < 3):
        print(" Invalid Input ")
        return
    first = second = third = -sys.maxsize
    for i in range(0, arr_size):
        # First: if current element is bigger than first
        # => update first, shift
        if (arr[i] > first):
            third, second, first = second, first, arr[i]
        # Second: if current element is in between first and second
        #  => update second, shift
        elif (arr[i] > second):
            third, second = second, arr[i]
        # Third: if current element is in between second and third
        #  => update thirs
        elif (arr[i] > third):
            third = arr[i]
    return [first, second, third]

# array = [1, 23, 12, 9, 30, 2, 50]
# Driver program to test above function
print()
n = len(array)
lst = get_3_largest(array, n)
# lst.sort()
print("Three largest elements are: ", lst[0], lst[1], lst[2])